10 DEFINT A-Z:KEY OFF:PRINT "*** Graph Drawing ***":PRINT ""
11 L=0:LT=0:S#=0:M#=0:DIM LABEL$(24),VALUE#(24)
15 INPUT "Load from file? (Y/N)",F$:IF F$="y" OR F$="Y" THEN GOTO 400
20 PRINT "Hint: Input a single comma to end."
30 WHILE L<25: INPUT "Label,Value: ",T$,D#:IF T$="" OR D#<0 THEN GOTO 80
40 S#=S#+D#:IF D#>M# THEN M#=D#
50 K=LEN(T$)+7:LABEL$(L)=T$:VALUE#(L)=D#:IF K>LT THEN LT=K
60 L=L+1:WEND
80 INPUT "Save to file? (Y/N)",F$:IF F$<>"y" AND F$<>"Y" THEN GOTO 200
90 INPUT "Filename:",F$:OPEN F$ FOR OUTPUT AS #1:FOR I=0 TO L-1
100 PRINT#1,LABEL$(I);",";VALUE#(I):NEXT I:CLOSE #1
200 IF L<2 THEN PRINT "Minimum 1 item required":END
201 SCREEN 2:CLS:W=638-LT*8:FOR I=0 TO L-1:D#=VALUE#(I)
210 LOCATE I+1,1,0:PRINT LABEL$(I);:LOCATE I+1,LT-6:PRINT USING "(##.#%)";D#/S#*100;
220 K!=D#/M#:LINE (LT*8+1,I*8)-(K!*W+LT*8+1,I*8+6),,BF
230 NEXT I:WHILE INPUT$(1)="":WEND:CLS
240 PI#=3.141592654:PI2#=PI#*2:DIM PAT$(16):FOR I=0 TO 13:READ C
241 FOR J=1 TO C:READ N:PAT$(I)=PAT$(I)+CHR$(N):NEXT J:NEXT I
250 Y=(25-L)/2:K1#=0:FOR I=0 TO L-1:D#=VALUE#(I)
260 LOCATE Y+I+1,3:PRINT LABEL$(I);:LOCATE Y+I+1,LT+2-6:PRINT USING "(##.#%)";D#/S#*100;
270 LINE (0,(Y+I)*8)-(14,(Y+I)*8+6),1,B:COL=(I-1) MOD 14
280 IF I>0 THEN PAINT(3,(Y+I)*8+3),PAT$(COL)
290 K2#=K1#+D#:IF I=L-1 THEN AE#=PI2# ELSE AE#=K2#/S#*PI2#
300 IF I=0 THEN AB#=0.00001 ELSE AB#=K1#/S#*PI2#
310 CIRCLE (430,100),190,1,-AB#,-AE#,0.42
320 XP=430+(185)*COS((AB#+AE#)/2):YP=100-(78)*SIN((AB#+AE#)/2)
330 IF I>0 AND ABS(AE#-AB#)>PI#/180 THEN PAINT(XP,YP),PAT$(COL)
340 K1#=K2#:NEXT I:WHILE INPUT$(1)="":WEND:CLS:SCREEN 0:END
400 INPUT "Filename:",F$:OPEN F$ FOR INPUT AS #1
410 WHILE NOT EOF(1) AND L<25:INPUT #1,T$,D#:IF T$="" OR D#<0 THEN GOTO 450
420 S#=S#+D#:IF D#>M# THEN M#=D#
430 K=LEN(T$)+7:LABEL$(L)=T$:VALUE#(L)=D#:IF K>LT THEN LT=K
440 L=L+1:WEND
450 CLOSE #1:GOTO 200
500 DATA 1,255:DATA 2,170,85:DATA 2,255,170:DATA 2,0,170
510 DATA 4,136,68,34,17:DATA 4,17,34,68,136
520 DATA 8,128,65,34,20,8,20,34,65
530 DATA 6,136,68,34,17,34,68
540 DATA 3,68,255,68
550 DATA 4,119,187,221,238
560 DATA 4,238,221,187,119
570 DATA 8,127,190,221,235,247,235,221,190
580 DATA 6,119,187,221,238,221,187
590 DATA 3,187,187,0

